<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <div id="app">
    <father-page></father-page>
  </div>
  <script src="./vue.global.js"></script>
  <script>
    const { createApp } = Vue;
    const app = createApp({
      data() {
        return {
          name: 'CommonHead1'
        }
      }
    });
    // 子组件
    const ChildPage = {
      template: `
        <div>
          <h3>这是子组件</h3>  
          {{msg}}
          <hr/>
          {{title}}
        </div>
      `,
      // 子组件中定义 props属性接收 接收 prop会自动编译成实例的属性
      props: ['msg', 'title']
    }
    // 父组件
    const FatherPage = {
      template: `
        <div>
          <h2>这是父组件</h2>  
          <hr/>
          <child-page :msg="msg1" title="标题1"></child-page>
          <child-page :msg="msg2" title="标题2"></child-page>
        </div>
      `,
      data() {
        return {
          msg1: '父组件数据1',
          msg2: '父组件数据2'
        }
      },
      components: {
        ChildPage
      }
    }
    app.component('FatherPage', FatherPage)

    app.mount('#app')
  </script>
</body>
</html>